$(function () {
  // console.log($)
  // 头部
  $('#header').load('./pages/header.html', function () {
    $('.header_nav li a').each((index, item) => {
      item.onclick = function () {
        $('.header_nav li a').each((index, item1) => {
          $(item1)[0].classList.remove('header_triangle')
        })
        $(item)[0].classList.add('header_triangle')
        if (index == 0) {
          $('.header_bottom_pic').show()
        } else {
          $('.header_bottom_pic').hide()
        }
        console.log(item.innerText)

        if (item.innerText == '发现音乐') {
          $('#main').load('./pages/recommend.html', function () {

          })
        } else if (item.innerText == '我的音乐') {
          $('#main').load('./pages/myAudio.html', function () {

          })
        } else if (item.innerText == '朋友') {
          window.open('https://music.163.com/#/friend', '_black', '')
        } else if (item.innerText == '商城') {
          window.open('https://music.163.com/store/product', '_black', '')
        } else if (item.innerText == '音乐人') {
          window.open('https://music.163.com/st/musician', '_black', '')
        } else if (item.innerText == '下载客户端') {
          window.open('https://music.163.com/#/download', '_black', '')
        }
      }
    })
    $('.header_create').click(function () {
      window.open('https://music.163.com/#/login?targetUrl=/creatorcenter', '_black', '')
    })

    $('.header_bottom_nav_fx span').each((index, item) => {
      item.onclick = function () {
        $('.header_bottom_nav_fx span').each((index, item1) => {
          $(item1)[0].classList.remove('header_pic')
        })
        $(item)[0].classList.add('header_pic')

        // 加载中间的内容
        let page = $('.header_pic')[0].innerText
        if (page == '排行榜') {
          $('#main').load('./pages/rankingList.html', function () {
            $('.re_video').each(function () {
              $(this).mouseenter(function (index, item) {
                let dom = $(this)[0]
                $(dom.children[2].children[0]).hide()
                $(dom.children[2].children[1]).show()
              });

              $(this).mouseleave(function () {
                let dom = $(this)[0]
                $(dom.children[2].children[0]).show()
                $(dom.children[2].children[1]).hide()
              })
            })
          })
        } else if (page == '主播电台') {
          $('#main').load('./pages/djradio.html', function () {

          })
        } else if (page == '歌手') {
          $('#main').load('./pages/singer.html', function () {

          })
        }
        if (page == '推荐') {
          $('#main').load('./pages/recommend.html', function () {
            personalalbum()
            newalbum()
            indexList()
          })
        }
        if (page == '歌单') {
          $('#main').load('./pages/playList.html', function () {

          })
        }
        if (page == '新碟上架') {
          $('#main').load('./pages/newdisc.html', function () {

          })
        }
        if (page != '推荐') {
          clearInterval(bannertimer)
        }
      }
    })
  })

  $('#main').load('./pages/recommend.html', function () {

  })

  // 底部
  $('#footer').load('./pages/footer.html', function () {

  })
  //登录
  $('#log').load('./pages/login.html', function () {

  })

  $('#player').load('./pages/player.html', function () {

  })

  window.addEventListener('mousewheel', function (event) {
    if (event.ctrlKey === true || event.metaKey) {
      event.preventDefault();
    }
  }, {
    passive: false
  });

  //firefox
  window.addEventListener('DOMMouseScroll', function (event) {
    if (event.ctrlKey === true || event.metaKey) {
      event.preventDefault();
    }
  }, {
    passive: false
  });

})
